package com.jeeplus.modules.guide.service;

import com.jeeplus.modules.guide.entity.MobileOtherHQueue;
import com.jeeplus.modules.guide.entity.YmbcsLabel;
import com.jeeplus.modules.guide.entity.YmbcsMatter;
import com.jeeplus.modules.guide.entity.YmbcsMatterBszn;
import com.jeeplus.modules.guide.mapper.DockingOtherMapper;
import com.jeeplus.modules.guide.mapper.YmbcsMatterMapper;
import com.jeeplus.modules.guide.utils.DataUtils;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Map;

@Service
@RequiredArgsConstructor
@Transactional
@Slf4j
public class DockingOtherService {
    private final DockingOtherMapper dockingOtherMapper;

    @Transactional(readOnly = false)
    public int intoElectronicMaterial(String electronicMaterialsName,String materialsUrl,String materialsType,String loginId,String materialsItem,int level){
        //覆盖原来的文件 旧文件无效
        //String loginName = dockingOtherMapper.findTellOpenid(loginId);
        //if(DataUtils.isNotNull(loginName))loginId = loginName;
        dockingOtherMapper.updateOldMaterial(electronicMaterialsName,materialsType,loginId);
        return dockingOtherMapper.intoElectronicMaterial(electronicMaterialsName,materialsUrl,materialsType,loginId,materialsItem,level);
    }
    @Transactional(readOnly = false)
    public int intoElectronicMaterialGXID(String electronicMaterialsName,String materialsUrl,String materialsType,String loginId,String materialsItem,int level){
        //覆盖原来的文件 旧文件无效
        String loginName = dockingOtherMapper.findGXIDOpenid(loginId);
        if(DataUtils.isNotNull(loginName))loginId = loginName;
        dockingOtherMapper.updateOldMaterial(electronicMaterialsName,materialsType,loginId);
        return dockingOtherMapper.intoElectronicMaterial(electronicMaterialsName,materialsUrl,materialsType,loginId,materialsItem,level);
    }

    @Transactional(readOnly = false)
    public int  updateUserMaterialHistory(String loginId){
        return dockingOtherMapper.updateUserMaterialHistory(loginId);
    }

    public List<String> delUserMaterialHistory(){
        return dockingOtherMapper.delUserMaterialHistory();
    }

}
